package kit.edu.lego.gruppe3.levels.rollbridge;

import kit.edu.lego.gruppe3.levels.LevelSelector;
import kit.edu.lego.gruppe3.levels.LevelSolver;
import kit.edu.lego.gruppe3.levels.LevelSelector.Level;
import kit.edu.lego.gruppe3.levels.labyrinth.LabyrinthSolver;
import kit.edu.lego.gruppe3.levels.sumpf.SumpfSolver;
import kit.edu.lego.gruppe3.sensors.Scanner;
import lejos.robotics.subsumption.Arbitrator;
import lejos.robotics.subsumption.Behavior;

public class RollBridgeSolver implements LevelSolver
{

	@Override
	public void start()
	{
		finishPreviousLevels();
		Scanner.getGroundTypeAt(0,true);
		LevelSelector.getInstance().setCurrentLevel(Level.rollBridge);
		Behavior moveOverRolls = new MoveOverBridge();
		Behavior bridgeEnd = new RollBridgeEnd();
		Behavior[] behaviors = {moveOverRolls,bridgeEnd};
		
		Arbitrator arby = new Arbitrator(behaviors);
		arby.start();
		
		
	}
	
	private void finishPreviousLevels()
	{
		LabyrinthSolver.setLevelCleared(true);
		SumpfSolver.setLevelCleared(true);
	}
	
	@Override
	public String toString()
	{
		return "Rollbridge solver";
	}
	
	private static boolean levelCleared = false;
	
	public static boolean isLevelCleared()
	{
		return levelCleared;
	}
	
	public static void setLevelCleared(boolean cleared)
	{
		levelCleared = cleared;
	}

}
